package czy.demo.config.security;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/** 很奇怪，这个类序列化时会多出一个name属性，反序列化会报错 */
@JsonIgnoreProperties(ignoreUnknown = true)
public class DefaultUsernamePasswordAuthenticationToken extends UsernamePasswordAuthenticationToken {

    public DefaultUsernamePasswordAuthenticationToken(){super(null,null,null);}

    public DefaultUsernamePasswordAuthenticationToken(Object principal, Object credentials,
                                                      Collection<? extends GrantedAuthority> authorities){super(null,null,null);}
    @Override
    public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException {
        /** 什么都不做，因为此处父类方法会抛出异常，只能在构造函数中设置 */
    }
}
